package com.wego.service.impl;

import com.github.pagehelper.Page;
import com.wego.common.base.impl.BaseServiceImpl;
import com.wego.common.bean.PageBean;
import com.wego.entity.domain.Admin;
import com.wego.entity.domain.LoginLog;
import com.wego.entity.domain.User;
import com.wego.entity.query.AdminQuery;
import com.wego.entity.query.LoginLogQuery;
import com.wego.mapper.AdminMapper;
import com.wego.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl extends BaseServiceImpl<Admin> implements AdminService {

    @Autowired
    AdminMapper adminMapper;

    @Override
    public boolean isExistAdmin(Admin admin) {
        int count = adminMapper.selectCount(admin);
        if(count == 0)
            return false;
        else
            return true;
    }

    @Override
    public Admin selectOne(Admin admin) {
        Admin admin1 = adminMapper.selectOne(admin);
        return admin1;
    }

    @Override
    public PageBean<Admin> selectPage(AdminQuery adminQuery) {
        //设置分页信息
        Page<Admin> page = adminQuery.toPage();
        //查询数据
        List<Admin> admin = adminMapper.selectList(adminQuery);
        System.out.println("loginlogQuery = " +admin.toString());
        //将MyBatis提供的Page对象转换成我们自己的PageBean对象
        return new PageBean<>(page);
    }
}
